﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion
#if !MF
using System;
using System.Collections.Generic;
using XcoAppSpaces.Core;

namespace XcoAppSpaces.Contracts.Messaging
{
	/// <summary>
	/// Information about a worker that is needed to create a worker proxy.
	/// </summary>
	public class WorkerProxyInfo
	{
		/// <summary>
		/// The contract type of the worker.
		/// </summary>
		public Type ContractType { get; private set; }

		/// <summary>
		/// The name of the worker.
		/// </summary>
		public string WorkerName { get; private set; }

		/// <summary>
		/// The address of the space where the worker is hosted.
		/// </summary>
		public string WorkerAddress { get; private set; }

		/// <summary>
		/// The address of the space where the worker is hosted.
		/// </summary>
		public string WorkerIdentifier { get; private set; }

		/// <summary>
		/// The name of the transport service that should be used to send messages to the worker.
		/// </summary>
		public string CommServiceName { get; private set; }

		/// <summary>
		/// The id of the session that should be used to communicate with the worker.
		/// </summary>
		public Guid SessionID { get; private set; }

		/// <summary>
		/// List of attributes of the processors of this worker.
		/// </summary>
		public Dictionary<Type, XcoProcessorAttribute> ProcessorAttributes { get; private set; }

		/// <summary>
		/// Method that takes messages that should be sent from the proxy.
		/// </summary>
		public Action<MessageToSend> MessageProcessor { get; private set; }

		/// <summary>
		/// Creates a new WorkerProxyInfo.
		/// </summary>
		public WorkerProxyInfo()
		{
		}

		/// <summary>
		/// Creates a new WorkerProxyInfo.
		/// </summary>
		/// <param name="contractType">The contract type of the worker.</param>
		/// <param name="name">The name of the worker.</param>
		/// <param name="address">The address of the space where the worker is hosted.</param>
		/// <param name="identifier">Identifier of the worker, built out of the worker's type and name.</param>
		/// <param name="commServiceName">The name of the transport service that should be used to send messages to the worker.</param>
		/// <param name="sessionID">The id of the session that should be used to communicate with the worker.</param>
		/// <param name="processorAttributes">List of attributes of the processors of this worker.</param>
		/// <param name="messageProcessor">Method that takes messages that should be sent from the proxy.</param>
		public WorkerProxyInfo(Type contractType, string name, string address, string identifier, string commServiceName, Guid sessionID, Dictionary<Type, XcoProcessorAttribute> processorAttributes, Action<MessageToSend> messageProcessor)
		{
			this.ContractType = contractType;
			this.WorkerName = name;
			this.WorkerAddress = address;
			this.WorkerIdentifier = identifier;
			this.CommServiceName = commServiceName;
			this.SessionID = sessionID;
			this.ProcessorAttributes = processorAttributes;
			this.MessageProcessor = messageProcessor;
		}
	}
}
#endif